﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BLO
{

    /// <summary>
    /// Summary description for Entrycs
    /// </summary>
    public class Entry
    {
        DTO.Entry info;
        DAO.Entry entryDAO;

        public Entry()
        {
            this.entryDAO = new DAO.Entry();
            this.info = new DTO.Entry();
        }

           /// <summary>
        /// Entry Information.
        /// </summary>
        public DTO.Entry Info
        {
            get { return this.info; }
            set { this.info = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        public static Entry GetEntry(String ID)
        {
            DAO.Entry entryDAO = new DAO.Entry();
            Entry entry = new  Entry();
            entry.Info = entryDAO.GetEntry(ID);
            return entry;
        }

        /// <summary>
        /// Insert Entry information to database.
        /// </summary>
        public bool Insert()
        {
            return (entryDAO.InsertEntry(this.info) !=0);
        }

        /// <summary>
        /// Update information to database.
        /// </summary>
        public void Update()
        {
            entryDAO.UpdateEntry(this.info);
        }

        /// <summary>
        /// Re-get all information from database about this Entrys.
        /// </summary>
        public void Refresh()
        {
            this.info = entryDAO.GetEntry(this.info.ID.ToString());
        }

        /// <summary>
        /// Delete this news from database.
        /// </summary>
        public void Delete()
        {
            entryDAO.DeleteEntry(this.info);
        }
    }
}